I have many different regex patterns automatically loaded everytime my greasemonkey script starts. 95% of this loaded memory isn't needed at any stage, so I would like to find a way to not even put that data into memory to begin with if I know it won't be used.
Take this a basic example:
var patterns = [
{
name : 'p1',
url : 'http://www.someurl.com',
pattern1 : /./,
pattern2 : /./,
pattern3 : /./,
},
{
name : 'p2',
url : 'http://www.someurl2.com',
pattern1 : /./,
pattern2 : /./,
pattern3 : /./,
},
{
name : 'p3',
url : 'http://www.someurl3.com',
pattern1 : /./,
pattern2 : /./,
pattern3 : /./,
},
];
....and many more patterns.
I don't need to load any of the data if the url does not match the current url (location.href).