Use free CDN hosting for netteForms.js

5 years ago

Felix
Nette Core | 889
+
0
-

Hi,

I have found this free CDN hosting (jsDelivr).

It would be nice have netteForms.js in CDN.

For example:

<!-- normal -->
<script src="//cdn.jsdelivr.net/nette/2.1/js/netteForms.js"></script>
<!-- via Google Closure Compiler -->
<script src="//cdn.jsdelivr.net/nette/2.1/js/netteForms.min.js"></script>

What do you think?

5 years ago

Majkl578
Moderator | 1379
+
0
-

I know cdnjs:http://cdnjs.com. They let you add your library if it has more than 100 stars on GitHub.

I personally don't like the idea that much, it is an additional DNS request just to get few kilobytes of code…

5 years ago

Tomáš Votruba
Moderator | 1154
+
0
-
  • I see advantage in easier way to keep updated, compared to composer, where I have to move the actual file.

@Majkl578: I think this is not about forcing using it, but having it in cnd in case you would like to (like Bootstrap etc.).

5 years ago

Honza Marek
Member | 1674
+
0
-

Tomáš Votruba wrote:

  • I see advantage in easier way to keep updated, compared to composer, where I have to move the actual file.

Actually when you use WebLoader or grunt.js (and you should), you have it updated after composer update for free.

5 years ago

petr.pavel
Backer | 492
+
0
-

A CDN has a positive effect only if:

  1. browser hits a limit for # of open connections per domain – thus a different domain counts towards a different limit and is downloaded immediately, doesn't wait for other connections to finish
  2. or if enough sites use the same CDN and therefore the browser already has it in its cache

Negative effects:
1] extra DNS + http(s) request (as Majkl578 pointed out)
2] security weakness – as with any CDN, you're linking to a third party script/location and you cannot guarantee that it hasn't been compromised

5 years ago

Tomáš Votruba
Moderator | 1154
+
0
-

Good idea, Honza. How do you use it?

5 years ago

Honza Marek
Member | 1674
+
0
-

Example of WebLoader config in config.neon:

webloader:
  js:
    default:
      files:
        - jquery.js
        - knockout.js
        - %appDir%/../libs/nette/nette/client-side/netteForms.js
        - {files: "*.js", from: %appDir%/js/src}

Example of Gruntfile.js part:

grunt.initConfig({
    concat: {
        options: {
            separator: ';'
        },
        dist: {
            src: [
                'www/libs/jquery.js',
                'www/libs/knockout.js',
                'libs/nette/nette/client-side/netteForms.js',
                'app/js/src/**/*.js'
            ],
            dest: 'www/generated/web.js'
        }
    }
});

5 years ago

Tomáš Votruba
Moderator | 1154
+
0
-

Thanks Honza. Do you personally prefer WebLoader or grunt? I'm currently using WebLoader and wondering about moving to grunt (concat info).

Last edited by Tomáš Votruba (2014-04-14 07:31)

5 years ago

David Grudl
Nette Core | 6790
+
0
-

CDN already exists http://nette.github.io/…etteForms.js

Using untrusted CDN is a huge security problem.

5 years ago

Majkl578
Moderator | 1379
+
0
-

GitHub.io is not a true CDN. Also, the script is not versioned.

Tomáš Votruba: English forum, so use english, not czech.

5 years ago

Tomáš Votruba
Moderator | 1154
+
0
-

Majkl: fixed

5 years ago

Honza Marek
Member | 1674
+
0
-

Tomáš Votruba wrote:

Thanks Honza. Do you personally prefer WebLoader or grunt? I'm currently using WebLoader and wondering about moving to grunt (concat info).

I am not sure yet. I have recently tried grunt in one project and it seems that both solution work.

5 years ago

bazo
Member | 625
+
0
-

netteForms are also on bower, just add “nette-forms”: “*” to your bower.json