
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
@wordpress/asset-loader
Advanced tools
Utility to dynamically load WordPress scripts and styles with dependency resolution.
Utility to dynamically load WordPress scripts and styles with dependency resolution.
This package provides a function to dynamically inject WordPress assets (scripts and styles) into the DOM with:
wp_enqueue_script/wp_enqueue_style behaviorInstall the module:
npm install @wordpress/asset-loader --save
import loadAssets from '@wordpress/asset-loader';
const assets = {
scripts: {
'wp-blocks': {
src: 'https://example.com/wp-includes/js/dist/blocks.min.js',
deps: [ 'wp-element', 'wp-data' ],
version: '1.0.0',
in_footer: true,
},
},
styles: {
'wp-block-library': {
src: 'https://example.com/wp-includes/css/dist/block-library/style.min.css',
deps: [],
version: '1.0.0',
media: 'all',
},
},
inline_scripts: {
before: {},
after: {
'wp-blocks': 'wp.blocks.registerBlockType(...)',
},
},
inline_styles: {
before: {},
after: {},
},
};
await loadAssets(
assets.scripts,
assets.inline_scripts,
assets.styles,
assets.inline_styles
);
import { resolveSelect } from '@wordpress/data';
import { store as coreDataStore } from '@wordpress/core-data';
import { unlock } from './lock-unlock';
import loadAssets from '@wordpress/asset-loader';
async function loadEditorAssets() {
// Get assets from the REST API endpoint
const assets = await unlock(
resolveSelect( coreDataStore )
).getEditorAssets();
// Load them into the DOM
await loadAssets(
assets.scripts || {},
assets.inline_scripts || { before: {}, after: {} },
assets.styles || {},
assets.inline_styles || { before: {}, after: {} }
);
}
Loads WordPress assets with dependency resolution.
Record<string, Script> - Map of script handles to script dataRecord<'before' | 'after', Record<string, string | string[]>> - Inline scriptsRecord<string, Style> - Map of style handles to style dataRecord<'before' | 'after', Record<string, string | string[]>> - Inline stylesPromise<void> - Resolves when all assets are loaded and executed
type Script = {
src: string;
deps?: string[];
version?: string;
in_footer?: boolean;
};
type Style = {
src: string;
deps?: string[];
version?: string;
media?: string;
};
in_footer flagasync=false for order)See CONTRIBUTING.md.
GPL-2.0-or-later
FAQs
Utility to dynamically load WordPress scripts and styles with dependency resolution.
The npm package @wordpress/asset-loader receives a total of 155 weekly downloads. As such, @wordpress/asset-loader popularity was classified as not popular.
We found that @wordpress/asset-loader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 23 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.