Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@googlicius/load-assets
Advanced tools
Readme
Utilities to load assets programatically: javascript, css, images,...
I am a fan of using javascript libraries from their CDN rather than include them in the application bundle. If you are building application with React.js, Angular, or Vue.js, there are many wrapper of libraries you need. But it causes a problem called bi-incompatible
(that's what I call it) when you upgrade your framework to latest version. Some javascript libraries doesn't support npm installation, or you just want to load it as lazy way (when user reach a specific page).
npm install @googlicius/load-assets
Or Yarn
yarn add @googlicius/load-assets
import { loadScript } from '@googlicius/load-assets';
loadScript(
'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js',
).then(() => {
// Lodash available here.
});
Loads and runs 2 javascript files in parallel.
loadScript(
'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js',
'https://connect.facebook.net/en_US/sdk.js',
).then(() => {
// Lodash and Facebook SDK available here.
});
Load 2 javascript files in parallel but runs in order, which means the second script depends on the first one.
loadScript([
'https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/prism.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/plugins/autoloader/prism-autoloader.min.js',
]).then(() => {
// Prism initialized with its autoloader.
});
Often a library is not only have javascript but also with its own css file.
So to load css and js we simple use loadAsset
:
import loadAsset from '@googlicius/load-assets';
loadAsset(
'https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/themes/prism-twilight.min.css',
'https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/prism.min.js',
).then(() => {
// Prism initialized with its styles.
});
Load with custom attributes:
loadScript('https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/prism.min.js', {
'data-manual': 'true',
}).then(() => {
// ...
});
MIT
When you upgradge your framework to higher version, but that version possibly incompatible with some library wrappers in your project, or you want to use the latest version of a library but it possibly haven't supported. For example, Reactstrap currently support Bootstrap 4, so you cannot use Bootstrap 5 at this time.
FAQs
Load assets helper
The npm package @googlicius/load-assets receives a total of 7 weekly downloads. As such, @googlicius/load-assets popularity was classified as not popular.
We found that @googlicius/load-assets 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.