I just do something like this so long :
wp_add_inline_script('helloworld','var site_config ='.json_encode($site_config));
Related Posts:
- How to add extra attributes to the script tag added via wp_localize_script()
- Setting HTML properties in a Gutenberg plugin using WordPress settings
- Script Localization doesn’t work
- Enqueue scripts all over but not in single.php
- Getting a variable inside foreach from PHP to JS after localization
- How to pass data to javascript in custom widget class
- Define a global variable in a JavaScript function
- How do you check if a variable is an array in JavaScript?
- How can I determine if a variable is ‘undefined’ or ‘null’?
- Static variables in JavaScript
- What does ${} (dollar sign and curly braces) mean in a string in Javascript?
- Declaring multiple variables in JavaScript
- How can I check if an element exists in the visible DOM?
- How to interpolate variables in strings in JavaScript, without concatenation?
- JavaScript check if variable exists (is defined/initialized)
- wp_add_inline_script without dependency
- How to use wordpress default Password Strength Meter script
- What are the benefits of using wp_enqueue_script?
- Is there a JavaScript API? How to access public and private data in JS?
- wp_enqueue_script() not working at all
- How to dequeue a script?
- How to use wp_localize_script in custom page template?
- How to use Head JS with all enqueued scripts?
- wp_enqueue_script : how to change loading order of scripts?
- Remove extra Google Maps script
- Is it possible to enqueue the Youtube API script or does it have to be inline?
- Include jQuery UI as a whole
- How to echo JS right after enqueued script to put it into noConflict mode?
- Correct place to register and enqueue scripts
- Combine enqueue js without affecting dependencies
- Load multiple Javascript scripts
- WP script versioning breaks cross-site caching?
- How do I enqueue(or delay loading of) tags in individual page posts?
- How to localize value of posts
- How to overwrite JS variable with wp_localize _script?
- Javascript not included
- Move all the JS files to the bottom|footer, the right way
- Javascript not working?
- wp_enqueue_script adds only the first script
- How to add JavaScript file using wp_enqueue_scripts?
- Remove type attribute from script added by wp_localize_script
- wp_enqueue_script & constants?
- Can the index.asset.php file be used with the enqueue_block_editor_assets action?
- wp_enqueue_scripts is not working in my plugin
- How to place script in footer?
- Exclude JS file from 404 error page
- Building a slide down search box in wordpress
- Using wp_localize_script inside template page to transfer var from php to js
- Enqueue Javascript After ALL Other Scripts (Including Async Scripts)
- Enqueue js script to footer
- Enqueueing a script and a style sheet not working
- Adding a Javascript slideshow to the home page
- Media library not working with wp_editor() on the front end
- how to localized scripts of new page requested by ajax?
- Override do_item() Function to Add Extra Attribute to Scripts
- wp_enqueue_script not loading my custom js file
- Scripts not loading through function Method in WordPress Theme
- How to execute Javascript on a WordPress page?
- Why is JavaScript being added to header as application/oembed?
- wp_enqueue_scripts not enqueing correctly
- Video script issue, JavaScript attribute remains ‘undefined’
- in jquery read a multidimensional array via wp_localize_script()
- How can I get user data into a javascript object?
- Add crossorigin to SCRIPT tag
- Add script to page at certain location in wordpress
- WordPress wp_enqueue_script only adds text to top of page source
- How do I know if I should enqueue JS code or just include it in ONE PHP function?
- JavaScript Libraries in WordPress
- Failing to load my script files in wordpress! i can’t figure out what i’m doing wrong
- Setting Variable Path to Template Directory inside Script
- wp_enqueue_script does not recognize my js file?
- Bootstrap bundle present in page source but not working
- Get localize of a loaded javascript
- Dynamically add Js
- JS / jQuery in Elementor pages vs JS file
- Load JavaScript on specific page with @wordpress compiler
- How to load Javascript code or functions.php later in a child theme?
- Enqueued script fails
- Loading two versions of same JS libary
- Proper way of minifiying java script files in wordpress theme
- Escaping quotes while enqueuing scripts
- How to make sure, that only the selected post is changing?
- How to register or enqueue script and stop it being called in head?
- How to correctly load this jquery script through the file functions.php?
- How to delay display of page elements until enqueued script has injected html
- Enqueue concatinated JS file in WordPress
- wp_enqueue_scripts doesn’t work for template pages
- Javascript file doesn’t load
- early enqueueing javascript file in page template, not in functions.php
- Dequeue set-post-thumbnail.min.js
- jQuery + more won’t load in header
- WOW.js Script Tag Initialization Header/Footer
- JS enqueue path (localhost)
- wp_localize_script not create variable in head section
- Script loaders vs wp_enqueue_script
- convertEntities() used before it is defined
- JavaScript file successfully registered but does not render correctly
- wp_enqueue has a resource but doesn’t generate a script tag [duplicate]
- Orbit Slider and Events Manager Plug-in JavaScript
- Uncaught ReferenceError: tippy is not defined