External scripts work with clojurescripts

A important concept in optimising web site is to reduce the number of files and compress them. Lein-cljsbuild for Clojurescript is doing a great job. It combines various cljs files together and compile them to one js file together with removing unnecessary codes and whitespaces. But when there are any external js in the project files, how to manage them is an issue.

This article provides some approach to do so. I also have already doing research on this for some time. And I think I need to take some note for record.

I was highly expected the :extern approach. I was considered this approach as some way to attach the contents of the js file to the compiled js file for cljs. But I cannot find anything form the extern js file in the compiled file. But the compiler throws warning for the extern js file. I am not very sure what did it do.

I also tried the :foreign-libs approach but still get nothing after compilation. I think I was misunderstood the manual, but I don't which part.

The final approach to resolve this issue is to attach <script> tag in to the webpage after all of the compiled js file are loaded.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.