
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Asynchronous JavaScript loader for client such as Google Map API, Twitter widget,...
Asynchronous JavaScript loader for client such as Google Map API, Twitter widget,...
yarn add js-fetch
jsFetch(CDNPath [, variablePath = null [, attributes = {} [, timeout = 15000]]])
positional arguments:
CDNPath url path(ex: https://maps.googleapis.com/maps/api/js)
variablePath variable global support path string (ex: 'google', 'google.maps.Map')
attributes attributes in script tag (ex: {async: true})
timeout timeout for waiting load CDNPath
<script src="//unpkg.com/js-fetch"></script>
<div id="map" style="width: 100%; height: 400px"></div>
jsFetch('//maps.googleapis.com/maps/api/js?key=YOUR_API_KEY', 'google', { async: true, id: 'abc' }, 5000).then(function(google) {
new google.maps.Map(document.querySelector('#map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
});
}).catch(function(err) {
// throw err;
});
import jsFetch from 'js-fetch';
Vue.component('my-component', {
template: `
<div>
<div ref="map" style="width: 100%; height: 400px"></div>
</div>`,
mounted() {
jsFetch(
'//maps.googleapis.com/maps/api/js?key=YOUR_API_KEY',
'google.maps.Map',
)
.then(Map => {
new Map(this.$refs.map, {
center: {lat: -34.397, lng: 150.644},
zoom: 8,
});
})
.catch(err => {
// throw err;
});
},
});
import jsFetch from 'js-fetch';
class App extends Component {
componentDidMount() {
jsFetch('//maps.googleapis.com/maps/api/js?key=YOUR_API_KEY', 'google')
.then(google => {
new google.maps.Map(this.map, {
center: {lat: -34.397, lng: 150.644},
zoom: 8,
});
})
.catch(err => {
// throw err;
});
}
render() {
return (
<div className="App">
<div
style={{width: '100%', height: '400px'}}
ref={map => {
this.map = map;
}}
/>
</div>
);
}
}
MIT © Nghiep
FAQs
Asynchronous JavaScript loader for client such as Google Map API, Twitter widget,...
We found that js-fetch 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.