What’s the best way to share snippets across our pages? We have all of our inline Javascript in a static resource, which is nice and neat, but our snippets are currently sitting within each page as a local resource. Should we extract the snippets out to our static resource and wrap them in the registerSnippet construct?
Page 1 / 1
Short answer: yes Long answer: extract the snippets into the StaticResource. Every JavaScript Resource of type “Inline (Snippet)” can be refactored into a StaticResource like this:
(function(skuid) { skuid.snippet.registerSnippet('SNIPPET_1_NAME',function(){ SNIPPET_1_BODY }); skuid.snippet.registerSnippet('SNIPPET_2_NAME',function(){ SNIPPET_2_BODY }); })(skuid);
Perfect. That’s just what we need. Thanks.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.