Q: 1.) Is this browser compatible?
Yes, for all browsers supporting jQuery data(). jQuery is generally supported by most modern browsers.
Q: 2) Are there any security concern to be aware of as compared to using wp_localize_script?
wp_localize_script()
is mainly doing the same but it’s keeping the data on the serverside and not within the DOM.
As always, making use of javascript and interacting with the DOM has security implications. You need to follow the rules to properly en- and de-code any arbitrary data safely so that injections can not introduce unintended behaviour.
Related Posts:
- How to remove hardcoded characters from playlists?
- Conditionally loading JavaScript based on the Advanced Custom Fields in the post
- Understanding WordPress child theme custom JS loading
- Use different javascript files for each page on website
- Trigger popup in a php if/else statement
- How to prevent XSS alter custom global javascript object & methods in WordPress
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- Need Help Fixing My Iframes [closed]
- Menu jumping when calling it via PHP
- How to add API security keys into JS of wordpress securely
- wp_nav_menu not working correctly in my underscores theme
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- How to extend SelectControl with data from my theme
- $.ajax results in 403 forbidden
- register dependency css and js inside a plugin class
- Collapsible menu on post sidebar only expands and does not collapse
- How to send Ajax Call from frontend without using wp_localize_script in Theme
- Retrieve $_POST data to send to javascript without using localize script
- 404 error on page reload
- WP Bootstrap NavWaker: Dropdown Menu Opens All Dropdown Menus at Once
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- Uncaught TypeError: Cannot read property ‘firstChild’ of null after upgrading to WordPress 5.5
- Using Font Awesome as post thumbnail
- Can I change a variable in a content part while calling it?
- Display notification only once
- How to make thumbnail image fit into a div where image dimentions are completely different?
- Access/update database with jQuery
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- Use WordPress’s Media Uploader/ Manager in non WordPress php application
- Get/Set wp.customize.previewer.previewUrl
- javaScript in section of WP API
- Why WordPress architecture is not pure object oriented and it don’t use MVC pattern? [closed]
- Custom Logo URL | Help me print the URL of the custom logo I inserted into my theme
- When must I use and verify nonce?
- admin-ajax.php responding with 0
- Using wp_localize_script to store the template url into a variable to use in JS
- How to display recent posts on home page with custom HTML
- How can the plugin directory path be returned into ?
- Hiding WordPress Plugin Source Code
- Is this code malidcous
- Remove annoying WP Adminbar CSS
- How can I add tinymce editor in WordPress with jQuery?
- What is the fastest way to load PHP functions that are only used in one theme template?
- How to speed up admin-ajax.php in wordpress
- My Own layout in WooCommerce pages [closed]
- JQuery not working on WordPress Admin page [closed]
- Customizer Show/Hide
- Page Reloads Before AJAX Request Finishes
- Differences when using the the_time and the_date functions
- Exclude posts from homepage having a specified tag
- Why is this Ajax not working?
- How do I access the media settings
- How do themes render caption texts in extended markup (e.g. “wp-caption” paragraphs)
- Changing the template hierarchy
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- How to make custom total price reactive in navigation
- Adding tawk.to code just before body tag on functions.php file
- using add_action for a header hook that has an additional parameter
- How do I fetch all comments per post via WP REST API?
- Deregistering a script in WordPress seems impossible
- Slide in Panel WordPress Post
- custom shortcode will not display the wrapped content
- Sending jsPDF documents to the server
- Admin username and password
- How to prevent those PHP variables from being cached on WordPress?
- Ajax return code 400
- Can’t load WP function into external function
- How can I add an alert (like the old javascript alerts) to my WP page?
- Pass PHP variable to JavaScript without inline JS
- Custom category code not showing all posts
- Displaying theme options in css
- Show post in slider
- How can I output a php value into a JS file within WordPress?
- max_input_vars: how many am I using?
- Evaluations of two wordpress security plans against php code injection attack
- Using shipped version of jquery
- Putting PHP variables into javascript [duplicate]
- How to show a dynamic_sidebar if main content content’s height is > a set amount?
- Bridging TinyMCE js and WordPress PHP?
- Set WordPress Default Template
- Trying to implement Ajax comments in WordPress, getting WP error
- How to test nonce with AJAX – Plugin development
- How do I display a user’s previous orders as a select box option on a product?
- Simple Plugin with custom javascript wont work – no console error
- How does this WordPress Plugin (Thrive Comments) apply their custom comment sort? [closed]
- How can I use a modal window to display the current post in loops featured image?
- Adding country tags automatically
- write custom woocommerce templates and forms
- Implement toggle switch for theme options in settings API
- js file in root loading without
- Using a `Template Parts` folder instead of an `Includes` folder in a Custom WordPress Theme
- class click counter save number
- Using a variable in is_page(array())
- Anyway to output the registration form like the login form with wp_login_form()?
- How do I get current page ID in WordPress customizer file?
- WordPress custom login form using Ajax
- Customizer: Output default value in Customizer CSS
- How to load a template-part based on a url wildcard?
- WordPress does not load page.php, return 404.php
- Slider loading issue