If the plugin does not include a priority, then the priority is “10” (the default).
So without changing (editing) the offending plugin, you can use a priority higher than 10 to load after, or lower than 10 to load earlier.
You mentioned that you want yours to load earlier. If that’s the case, the priority in your example is backwards. Setting foreign-plugin to 1 means it will load before my-plugin (set to 2). Instead, it should be:
add_action('wp_enqueue_scripts', '<FOREIGN-PLUGIN>', 2);
add_action('wp_enqueue_scripts', '<MY-PLUGIN>', 1);
Then “<MY-PLUGIN>
” will load earlier than “<FOREIGN-PLUGIN>
“. But as I mentioned, if it’s already in another plugin, you shouldn’t edit that and the default prior, so your enqueue should simply be:
add_action('wp_enqueue_scripts', '<MY-PLUGIN>', 1);
(Or some priority number from 1-9). Then “my-plugin” will enqueue first.
Related Posts:
- Get list of scripts / styles and show file which enqueued them
- How to avoid loading same script twice?
- How to load library scripts in admin from plugins in noConflict wrapper?
- ajaxurl not defined on front end
- How to add a javascript snippet to the footer that requires jQuery
- How to enqueue JavaScripts in a plugin
- How to include jQuery and JavaScript files correctly?
- Conditionally enqueue a widget’s script/stylesheet in HEAD (only when present on page!)
- Load js/css files only on specific admin UI pages
- jQuery in header or footer
- Enqueue script only when shortcode is used, with WP Plugin Boilerplate
- How do I conditionally enqueue script for CPT single post type with plugin?
- Where to enqueue stylesheets for plugin?
- When is it too late to call the action wp_enqueue_scripts?
- Use js script from one plugin in another plugin
- Script won’t load via plugin class
- Plugin Loading Scripts and Styles on Every Page – Even when not being used
- Inserting JS snippet in the footer if there is no wp_footer?
- Can’t get JS code to work with shortcode
- How do you output enqueued scripts to an admin page?
- How do I add a javascript file to all admin pages via a plugin?
- Multisite plugin development and wp_enqueue_script
- is_page() function doesnt working
- How to run a external JavaScript file on wp-admin if admin, and other if normal user?
- Enqueue scripts in footer
- Loading scripts with wp_register_script and wp_enqueue_script
- Adding Dropbox dropin js using wp_enqueue_script
- Where to call wp_enqueue_script in a plugin with custom template?
- Replacing Scripts in Admin Load_Scripts
- Is there a way to ensure plugin script loads before another script?
- conditionally load javascript & CSS for do_action() calls from plugin
- Correct check for any admin page with editor
- What stylesheets are available in core?
- How to enqueue or include json file to a plugin
- jQuery does not enqueue for my purpose… (before an inline script in the footer)
- Enqueue script globally
- WP Plugin Running before jQuery
- wp_localize_script is not adding a global variable for javascript
- Loading Modernizr (or other JavaScript libraries) for use in a plugin
- should i be checking for jquery before enqueing it in a plugin
- How to import the css in the plugin admin area?
- My stylesheets are not enqueuing
- Plugin Development – Class Constructor Not Firing wp_enqueue_style action hook
- Custom Plugin – CSS works, JS doesn’t
- Enqueuing scripts and styles in custom plugins
- How to enqueue scripts in right way in a plugin?
- unable to wp_enqueue_script(‘suggest’);
- How to make my shortcode load scripts and styles, from within the plugin?
- How do I get rid of my inclusion race-condition on wp_enqueue_script
- Completely isolate a plugin view so it doesn’t load the theme
- How to Get Rid of Unwanted Backslashes in WordPress Form Input inside admin menu option
- Using function from enqueued .js file in theme in plugin?
- Enqueue a file that’s not js or css
- Enqueueing common php scripts in a plugin
- Enqueue scripts inside a class in a plugin
- Enqueue ONLY Plugin Styles and Scripts
- wp_enqueue_scripts in a plugin’s class
- WordPress Plugin Authoring question about jquery and css
- Loading Images from Javascript on the Front End
- Integrating a Gutenberg custom block within a larger plugin
- Add default value from selection
- Can’t load a script in my plugin page
- Is “document loaded” different on admin side than public side?
- plugin css is not being applied to the page
- Adding External Gmap JS to WordPress
- How do I ensure I can loop through every enqueued script and CSS?
- Append php file to footer
- How to avoid conflict if a plugin already have included open library?
- AJAX call of function containing javascript which is not loaded (Plugin development)
- Javascript not being loaded only in custom taxonomy template
- Ajax Response Error | just getting error as the response
- Add a Script button in W3 Total Cache plugin not working due to conflicting jQuery version
- Enqueue scripts based on site.
- How to enqueue an external Javascript file to Frontpage footer
- Enqueue script not working
- Script work on non logged in user but not work for logged in user?
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- Correct usage of scripts with shortcodes
- How to only Load scripts on variable products page
- How to fork a plugin?
- Displaying search results in the widget itself?
- How to duplicate a curl XML request using HTTP API?
- Help with enqueing scripts in footer after init action
- How to add pages to custom menus on the fly [duplicate]
- How to add settings subpage from a plugin to a settings page created in theme?
- how query string in wordpress receive the value other than post and page [duplicate]
- Is there an event or an other method that tells me the preview is loaded?
- Admin Plugin POST to another file within the plugin
- Plugin AJAX Save to Custom Table
- get_shipping_methods() return empty rate
- How to write a shopping queue line plugin with a queue button?
- WordPress shortcode with a switch
- Can i prevent the effect of the_title filter on the dashboard’s posts/pages titles?
- Moving the “share” button
- How to change the wording of front-end `next article` for custom type registered in a plug-in?
- Get (eventual) permalink from post within Edit Post in Admin panel
- Ajax not working to insert, query and result data
- Remove image in post when it’s removed in media library
- Is the only way to add taxonomy terms via an admin panel?
- Find Any Theme’s page.php File