
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
script-path
Advanced tools
Retrieves the path of the specified script on the page, used to dynamically load assets relative the current script.
Retrieves the path of the specified script on the page, used to dynamically load assets relative the current script.
npm install script-path --save
# bundleName is the final name of your bundle (without .min or .js)
var bundleName = 'app';
var scriptPath = require('script-path')(bundleName);
script-path returns the path to the script file as passed in, use it to load assets relative to your bundle, not to the page.
If your page is running at https://example.com/mypage
but it's loading your bundle from
https://cdn.somewhereelse.com/libs/myscript.min.js
, the following code will return
https://cdn.somewhereelse.com/libs/
.
var scriptPath = require('script-path')('myscript');
Webpack enables you to load chunks dynamically from your script, it uses a config setting publicPath
(https://github.com/webpack/docs/wiki/Configuration#outputpublicpath) to determine the path to load the chunks from,
however this means you either have to load them relative to the current page or know the exact URL at build time.
Rather than settings the publicPath
property you can include set the path at runtime by assigning it to
__webpack_public_path__
on your entry point. Using script-path you don't need to know where it's going to hosted
or where it's running from, you can query that at runtime, e.g.
__webpack_public_path__ = require('script-path')('myscript');
FAQs
Retrieves the path of the specified script on the page, used to dynamically load assets relative the current script.
The npm package script-path receives a total of 2 weekly downloads. As such, script-path popularity was classified as not popular.
We found that script-path demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.