Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How do I install and use enquire.js in a WordPress theme? WordPress

I want to use enquire.js ([[LINK href=""]][[/LINK]] to load another script conditionally based on a media query.

Right now I'm doing this with Modernizr:

test:'only screen and (min-width: 1000px)'),
yep : {
'yesResponse' : ''
callback: {
'yesResponse' : function () {
jQuery.backstretch( "" );

How would I do this with enquire.js? I need a step-by-step for using it in WordPress by setting up a media query-based test like the one shown below, please, targeted toward non-programmers.

enquire.register("screen and (min-width:45em)", function() {
// load another script

Answers (3)


Arnav Joy answers:

you can see following article for how you can add javascript to wordpress

kanjigirl comments:

I know how to add JS to WordPress, thanks. I need to see an example of how to use enquire.js in WordPress...

Arnav Joy comments:

firstly you have to add enquire.js to your's theme js folder and then a another file for writing js content


function my_scripts_method() {
wp_enqueue_script('enquire', get_stylesheet_directory_uri() . '/js/enquire.js', array( 'jquery' ) );
wp_enqueue_script('custom-script', get_stylesheet_directory_uri() . '/js/custom_script.js', array( 'jquery' , 'enquire' ) );

add_action( 'wp_enqueue_scripts', 'my_scripts_method' );


in custom-script.js add something like

enquire.register("screen and (min-width : 769px ) and (max-width : 959px)", {
match : function() {
unmatch : function() {

hope it will help you

Arnav Joy comments:

the php code will go in your theme's functions.php file


Giri answers:

Here is a tutorial.

[[LINK href=""]][[/LINK]]

kanjigirl comments:

I went through this tutorial, thanks. I need a WP-specific one.


Hariprasad Vijayan answers:


Check these threads