简体   繁体   中英

Why is the Javascript not loading on this WordPress plugin?

I have looked over carefully at the scripts file for a WordPress plugin I am developing and I also looked at a similar post:

javascript file not working when linked from HTML

but the answer above has not worked either. I am not sure why the javascript file is not loading.

Here is the includes/newsletter-subscriber-scripts.php:

<?php

// Add Scripts
function ns_add_scripts(){
        wp_enqueue_style('ns-main-style', plugins_url().'/newsletter-subscriber/css/style.css');
        wp_enqueue_script('ns-main-script', plugins_url().'/newsletter-subscriber/js/main.js');
}

add_action('wp_enqueue_scripts', 'ns_add_scripts');

Here is the javascript file that is not loading in /newsletter-subscriber/js/main.js:

alert('Linked');

Did you check it out that its enqueuing in front end you can see script tag in your HTML output? of its coming than might be your browser java-script is off. check it or you can add link to your site so than someone can debug it

thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM