get db values for external js file

You need to use wp_localize_script() when you enqueue the js script. It’s usually a good alternative of ajax way and this will save you to create multiple js files. wp_localize_script() can be used to make any data available to your script that you can normally only get from the server side of WordPress. As you … Read more

Make a script work within a page

I think both external CSS & JavaScript files should be added to your active theme functions.php file into function which implements action wp_enqueue_scripts. It should looks like example code below: <?php // … function themename_enqueue_scripts() { // … wp_enqueue_style(‘themename-slider-style’, ‘//scd01.bcnshop.com/ca/widgets/generate-css/1815/4150.css’, false ); wp_enqueue_script(‘themename-slider-js’, ‘//scd01.bcnshop.com/ca/widgets/generate-js/1815/4150.js’, array(‘jquery’) ); // … } add_action( ‘wp_enqueue_scripts’, ‘themename_enqueue_scripts’ );

How can I leverage browser cache for minified JS or minified CS files?

Yeah, you can do leverage browser caching for minified js & css files same as we do for other files. <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg “access 1 year” ExpiresByType image/jpeg “access 1 year” ExpiresByType image/gif “access 1 year” ExpiresByType image/png “access 1 year” ExpiresByType text/css “access 1 month” ExpiresByType text/html “access 1 month” ExpiresByType … Read more

Need help with customalert that it would read on a normal page, but not in WordPress

It seems that some elements that you’re referencing to on your JavaScript, do not exist by the time you execute the code. Elements that should exist before the JavaScript: dialogoverlay dialogbox dialogboxhead dialogboxbody dialogboxfoot Based on the error message, these elements DO exist: dialogoverlay dialogbox A few questions to clarify Did you check if the … Read more

WordPress load-scripts.php not loading

/** * add script * * https://developer.wordpress.org/reference/functions/wp_enqueue_script/ */ function youplugin_add_frontend() { // js wp_enqueue_script(‘youplugin-js’, get_template_directory_uri() . ‘/js/scripts.js’, array(‘jquery’), 0.1, true); } // add script add_action(‘wp_enqueue_scripts’, ‘youplugin_add_frontend’);