How can i call a javascript function from a file for pug?How to validate an email address in JavaScriptHow do JavaScript closures work?How can I upload files asynchronously?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?

Which GPUs to get for Mathematical Optimization (if any)?

Everyone but three

How would thermophilic fish survive?

How do you send money when you're not sure it's not a scam?

How fast does a character need to move to be effectively invisible?

Why are there few or no black super GMs?

Why did Fury respond that way?

May I use a railway velocipede on used British railways?

How did Jayne know when to shoot?

How to tell the object type of an Attachment

Why aren't there any women super GMs?

Amira L'Akum not on Shabbat

Who determines when road center lines are solid or dashed?

Why isn't a binary file shown as 0s and 1s?

Desecrating Shabbos to ask a Gadol to daven for a patient?

Is encryption still applied if you ignore the SSL certificate warning for self signed?

ANOVA or Linear Mixed Model?

Practical example in using (homotopy) type theory

Drawing a circle with nodes shift with Tikz

What were the problems on the Apollo 11 lunar module?

How to not confuse readers with simultaneous events?

How to remove the first colon ':' from a timestamp?

How to interpret a promising preprint that was never published?

The most secure way to handle someone forgetting to verify their account?



How can i call a javascript function from a file for pug?


How to validate an email address in JavaScriptHow do JavaScript closures work?How can I upload files asynchronously?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Heres my code but removed some changed code to something smaller!



Javascript code:




// /JS
function callme()
var test = 1
alert(test);





Pug code:



// /first.pug
var funct = require('../JS');
button(onclick='clickme()') click
script.
function clickme() ¨
// trying to call callme function from my javascript file but i really dont know how.
callme();



Sorry about this question i dont use pug but this was already made with pug so i cannot go changing it since it has alot more code but didnt post all not needed code here.










share|improve this question




























    0















    Heres my code but removed some changed code to something smaller!



    Javascript code:




    // /JS
    function callme()
    var test = 1
    alert(test);





    Pug code:



    // /first.pug
    var funct = require('../JS');
    button(onclick='clickme()') click
    script.
    function clickme() ¨
    // trying to call callme function from my javascript file but i really dont know how.
    callme();



    Sorry about this question i dont use pug but this was already made with pug so i cannot go changing it since it has alot more code but didnt post all not needed code here.










    share|improve this question
























      0












      0








      0








      Heres my code but removed some changed code to something smaller!



      Javascript code:




      // /JS
      function callme()
      var test = 1
      alert(test);





      Pug code:



      // /first.pug
      var funct = require('../JS');
      button(onclick='clickme()') click
      script.
      function clickme() ¨
      // trying to call callme function from my javascript file but i really dont know how.
      callme();



      Sorry about this question i dont use pug but this was already made with pug so i cannot go changing it since it has alot more code but didnt post all not needed code here.










      share|improve this question














      Heres my code but removed some changed code to something smaller!



      Javascript code:




      // /JS
      function callme()
      var test = 1
      alert(test);





      Pug code:



      // /first.pug
      var funct = require('../JS');
      button(onclick='clickme()') click
      script.
      function clickme() ¨
      // trying to call callme function from my javascript file but i really dont know how.
      callme();



      Sorry about this question i dont use pug but this was already made with pug so i cannot go changing it since it has alot more code but didnt post all not needed code here.






      // /JS
      function callme()
      var test = 1
      alert(test);





      // /JS
      function callme()
      var test = 1
      alert(test);






      javascript pug






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 26 at 9:53









      HeimotHeimot

      92 bronze badges




      92 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Pug has no capability to directly run JavaScript. It is used to generate HTML.



          You are already generating HTML with embedded client-side JavaScript.



          You need to write the HTML to include the external JavaScript.



          i.e. <script src="/url/to/JS.js"></script>



          In Pug that would be:



          script(src="/url/to/JS.js")


          Make sure your HTTP server gives the JS a public URL!






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55354165%2fhow-can-i-call-a-javascript-function-from-a-file-for-pug%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Pug has no capability to directly run JavaScript. It is used to generate HTML.



            You are already generating HTML with embedded client-side JavaScript.



            You need to write the HTML to include the external JavaScript.



            i.e. <script src="/url/to/JS.js"></script>



            In Pug that would be:



            script(src="/url/to/JS.js")


            Make sure your HTTP server gives the JS a public URL!






            share|improve this answer



























              1














              Pug has no capability to directly run JavaScript. It is used to generate HTML.



              You are already generating HTML with embedded client-side JavaScript.



              You need to write the HTML to include the external JavaScript.



              i.e. <script src="/url/to/JS.js"></script>



              In Pug that would be:



              script(src="/url/to/JS.js")


              Make sure your HTTP server gives the JS a public URL!






              share|improve this answer

























                1












                1








                1







                Pug has no capability to directly run JavaScript. It is used to generate HTML.



                You are already generating HTML with embedded client-side JavaScript.



                You need to write the HTML to include the external JavaScript.



                i.e. <script src="/url/to/JS.js"></script>



                In Pug that would be:



                script(src="/url/to/JS.js")


                Make sure your HTTP server gives the JS a public URL!






                share|improve this answer













                Pug has no capability to directly run JavaScript. It is used to generate HTML.



                You are already generating HTML with embedded client-side JavaScript.



                You need to write the HTML to include the external JavaScript.



                i.e. <script src="/url/to/JS.js"></script>



                In Pug that would be:



                script(src="/url/to/JS.js")


                Make sure your HTTP server gives the JS a public URL!







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 26 at 9:57









                QuentinQuentin

                676k78 gold badges919 silver badges1074 bronze badges




                676k78 gold badges919 silver badges1074 bronze badges


















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55354165%2fhow-can-i-call-a-javascript-function-from-a-file-for-pug%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript