Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I move CSS/JS scripts into the footer? #11

Closed
6 tasks done
jaswrks opened this issue Jan 20, 2015 · 7 comments
Closed
6 tasks done

How can I move CSS/JS scripts into the footer? #11

jaswrks opened this issue Jan 20, 2015 · 7 comments

Comments

@jaswrks
Copy link

jaswrks commented Jan 20, 2015


KB Article Creation Checklist
  • Write initial draft for this KB Article; label this issue draft and either questions or tutorials
  • Add required YAML configuration
  • Add Tags for this KB Article to the YAML config (see YAML Keys (Explained))
  • Edit and finalize draft for publishing (remove draft label, add draft-finalized label)
  • Assign Issue to yourself and create Markdown file (remove draft-finalized label, add pending)
  • Project Lead: Review and Publish KB Article (remove pending label, add published label)

:octocat: View Markdown File | ✏️ Edit Markdown File
📃 Published KB Article: http://zencache.com/kb-article/how-can-i-move-cssjs-scripts-into-the-footer/


@raamdev
Copy link
Contributor

raamdev commented Jan 21, 2015

Awesome article! I added the missing questions label.

@jaswrks
Copy link
Author

jaswrks commented Jan 21, 2015

I added the missing questions label.

Ah. Thanks! I forgot that was needed.

@raamdev raamdev changed the title How can I move combined JS/CSS files into the footer? How can I move JS/CSS files into the footer? Mar 22, 2015
@raamdev raamdev changed the title How can I move JS/CSS files into the footer? How can I move CSS/JS scripts into the footer? Mar 22, 2015
@raamdev raamdev self-assigned this Mar 22, 2015
@raamdev raamdev closed this as completed Mar 22, 2015
@raamdev raamdev added published and removed draft labels Mar 22, 2015
raamdev added a commit that referenced this issue Mar 22, 2015
@raamdev
Copy link
Contributor

raamdev commented Mar 22, 2015

raamdev added a commit that referenced this issue Feb 28, 2016
@raamdev raamdev removed their assignment Apr 28, 2016
@pkiula
Copy link

pkiula commented Feb 7, 2017

It'll be nice to have a sample of where and how the wp_enqueue thing can be put. In functions.php file?

@raamdev
Copy link
Contributor

raamdev commented Feb 7, 2017

@pkiula Please see the WordPress Developer Documentation: https://developer.wordpress.org/reference/functions/wp_enqueue_script/

@pkiula
Copy link

pkiula commented Feb 8, 2017

Thank you raamdev. Naturally I saw that, but it didn't completely do away with my doubts. Let's say I have the following scripts in the footer and I'd like Comet Cache to compress and minify them just before the closing body tag. Where should I put the wp_enqueue.. function. In my functions.php file? Thank you.

<!-- footer-scripts -->
    <script src="js/vendor/jquery.js"></script>
    <script src="js/vendor/jquery.transit.min.js"></script>
    <script src="js/vendor/what-input.js"></script>
    <script src="js/vendor/foundation.js"></script>
    <script src="app.js"></script>
<!-- footer-scripts -->

</body>
</html>

@raamdev
Copy link
Contributor

raamdev commented Feb 8, 2017

@pkiula Yes, functions.php would work. But if you've got a plugin or theme already enqueuing those scripts, you'll need to modify them to enqueue the scripts in the footer (the wp_enqueue_script() function accepts a $in_footer parameter that lets you define that the script should be loaded in the footer... you're not supposed to place the wp_enqueue_script() function in a special place to have it load the script in the footer...).

If you need help with WordPress functions and their usage, I recommend posting on the WordPress Support Forum. We reserve GitHub for filing bug reports, making feature requests, and submitting specific feedback related to our KB articles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants