noext.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>RequireJS noext! plugin</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. </head>
  8. <body>
  9. <div id="wrapper">
  10. <h1>RequireJS noext! plugin</h1>
  11. <p>Helper for loading files without appending the &quot;.js&quot; extension.</p>
  12. <p>
  13. Note that it will append a query string &quot;noext=1&quot; to the URL to avoid inserting the JS extension.
  14. </p>
  15. <h2>Output:</h2>
  16. <div id="output" style="border:1px solid #ccc; background:#f5f5f5; padding:10px 20px"></div>
  17. </div>
  18. <script src="../lib/require.js"></script>
  19. <script>
  20. require.config({
  21. paths : {
  22. noext : '../src/noext' //alias to plugin
  23. }
  24. });
  25. require(['noext!js/foo.bar', 'noext!js/foo'], function(foo1, foo2){
  26. var out = document.getElementById('output');
  27. //data is parsed into an object
  28. out.innerHTML += '<p><b>foo.bar:<\/b> '+ foo1.msg +'<\/p>';
  29. out.innerHTML += '<p><b>foo:<\/b> '+ foo2.msg +'<\/p>';
  30. });
  31. </script>
  32. </body>
  33. </html>