Is it good to organize array of data in js file? I have about 70 strings of data like (price sheet with id): 1,'LF5W13ZE0','289,19'
2,'BP0118110BKR5E11NGK','174,19'
And i want to load from it to html (using JQuery)? Using myArray[0] =.
Is it rational to load this big file via client? or better use PHP (server side)?
If you’d like to keep one place containing all products, you may use an external .js file.
A possible format for that external js file:
You can also use object literals like
{id: 'LF5W13ZE0', price:'289,19'}, but the idea remains the same.Another points to consider is whether the inclusion of the product details in a separate js file is worth the effort. You may run in issues if the js file was cached for example and need some way to insert the values from JS in the HTML.