When it comes to loading assets such as js
& css
from the next page and storing them in an Array
, I have implemented a method where I iterate through the document and store the JavaScript links separately. It currently looks like this:
0:{images: Array(61)}
1:{js: script}
2:{js: script}
3:{js: script}
4:{js: script}
5:{js: script}
6:{js: script}
etc...
Below is the loop in question:
[].forEach.call( document.querySelectorAll("script[src]"), function( src ) {
console.log( src );
resources.push({js: src})
});
My query is, how can I store these JavaScript links in one object like the images, instead of pushing them separately?