Use free CDN hosting for netteForms.js

Notice: This thread is very old.
Felix
Nette Core | 1040
+
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?

Majkl578
Moderator | 1364
+
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…

Tomáš Votruba
Moderator | 1110
+
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.).

Honza Marek
Member | 1664
+
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.

petr.pavel
Backer | 504
+
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

Tomáš Votruba
Moderator | 1110
+
0
-

Good idea, Honza. How do you use it?

Honza Marek
Member | 1664
+
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'
		}
	}
});
Tomáš Votruba
Moderator | 1110
+
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)

David Grudl
Nette Core | 7239
+
0
-

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

Using untrusted CDN is a huge security problem.

Majkl578
Moderator | 1364
+
0
-

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

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

Tomáš Votruba
Moderator | 1110
+
0
-

Majkl: fixed

Honza Marek
Member | 1664
+
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.

bazo
Member | 619
+
0
-

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