A better way to add Respond.js

In this tutorial I go over a better way to add the Respond.js file to our WordPress theme. This will make sure the script is only used in the Internet Explorer browser.

You need to have an active subscription to view this content.

Register Here!

  • Schmid Beda

    A question:
    Do we still need (in header.php) this line(s):

    <html id="ie8" >


    <html >
    <!–

    <script src="/js/html5.js” type=”text/javascript”>

    If we use above mentioned enqueue for IE8?

    • Please create a topic in the support forum with your markup.

  • Schmid Beda

    my comments get shortened, why?

    I signed up for 70 bucks, not sure if this is the place to put my doubts?

    • I am not sure why Disqus shortens comments. The service probably doesn’t allow HTML within comments. There is a member forum that you can ask any questions you would like. You can also email me directly on the Contact page.

  • Oana Gansca

    Hey,

    I followed the steps exactly but nothing happens and the link for respond.js does not appear in the pages code.

    What could be the reason for that, i have to mention that i am using the latest version of underscores and now my script source looks like this:

    • As long as you have the function that is listed in this tutorial in your functions.php file, the respond.js script should be added. It is going to be added in the header and probably wont be next to your other JS scripts. When you view the page source, do a command + F or control + F and search for respond.

      It would probably help to watch the video again to make sure you are adding the code in the correct files.

  • Patricia Ellis

    The video has not been available for the last 12 hours or so. Can I go forward with just the text below the video?

    • The video shows up and plays just fine for me? Do you have a slow internet connection maybe?

  • Jared Saunders

    Great tutorials so far – glad I found you.

    The CSS files are loading, but the JS files are not – none of the bootstrap or respond.js. Has anybody else been having problems loading JS files? I’ll keep looking for typos, but I’m pretty sure my code is exactly the same as the examples.

    • Jared Saunders

      …looks like I’m experiencing what Ooana Gansca (below) described. I hope it’s just a typo on my part.

      • I am sure you just missed a simple line of code. Jump in the forum and post your code if you are still having issues.

  • Hi Brad, Just curious with this method of adding the responds.js file in IE8 how will the browser know that respond.js is dependent upon jquery? Thank you and blessings<

    • It won’t know it requires jQuery, but if you have other JS scripts that you enqueue (which you should if you included Bootstrap JS) then jQuery will already be loaded before it hits this script in IE8. Hope this helps.

  • Mark

    Is the ‘ie_scripts’ what is known as a hook as it is using wp_head to add the code into the header.php? Sorry for the newb question, but I am not clear on this point.

    • ie_scripts in the function that we created that is going to insert the scripts into the WP head. It does this with the add_action. Notice we are hooking into the wp_head. You can read more about it here: https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head

      But WP has all kinds of actions you can hook into, you can even add your own to your theme! wp_head is the most commonly used.