I'm looking for the proper way to load strings into Javascript
code.
For example if I have about 300 strings like this one:
'<h1>Some text</h1>'
I want to load from some external source with loading of page.php
into JS
script.
I want avoid listing of strings as variables var v1 = '<h1>Some text</h1>';
or in list var lst = ["<h1>Some text</h1>", "<h1>Some text2</h1>"];
included to .js
, but load strings to array from outside.
One way is using of MySQL
database given the fact that static sequence is important to use ID
for assigning string values to special variables.
But I'm not sure if connection with database is a best, fast and soft way for this particular case, when list is not too big, requires static sequence, not dynamically updated and must be outside of .js
document and loaded in to array with page load.
I don’t see the point of loading from one .js
to another .js
, if my goal is remove listing from .js
. Мaybe I can use .xml
, or something else, more suitable what is possible.