-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow usage with AMD/CommonJS #20
Comments
Support for RequireJS means two things:
|
@ntkme I can not say anything about what this means internally and I don't want to set you under pressure to allow usage with RequireJS. However, if you want to win users like me you definitely need to allow a usage like any other plugin (download with Bower and use with RequireJS), as making an embed to a remote .js file seems to be unnecessary too. Regarding your second point, I don't know why this is an overkill for you document.addEventListener("DOMContentLoaded", function(event) {
// initialize plugin
}); |
It's an overkill because no one knows the when the asynchronous JavaScript would be load. It can be before DOM ready, where you have to listen for the event (the method you mentioned requires IE9+). It can also be after the DOM ready, where listen for the event has no effect, you just execute the code. The problem is that you want the code to be executed exactly once. Thus it requires a reliable way to detect if DOM is already loaded and listen for DOM ready. |
Well, the DOM ready has been done anyways. Why it's overkill? The compressed size of |
@julmot |
@ntkme Thank you for your effort. Unfortunately I still can't use it. In most RequireJS workflows almond will be used in production. As almond does not support network resources, it would be necessary to download this package using e.g. Bower. So you would also need to make it available to download with Bower. |
@julmot The support for Bower or any package manager is not going to happen. This project is intended to be a reliable button service, but not a package. Packing it with Bower will simply prevent users from receiving updates and fixes automatically. Although it is clearly against the design pattern of AMD, you can always write some JavaScript to inject (function(){
var js = document.createElement("script");
js.src = (/^http:/.test(document.location) ? "http" : "https") + "://buttons.github.io/buttons.js";
document.getElementsByTagName("head")[0].appendChild(js);
})(); Alternative, if you really want to use a package manger, it is possible to install it with npm install https://github.com/ntkme/github-buttons/archive/master.tar.gz |
Well, this is up to the developer. You can choose "latest" in the configuration and will always get the latest version on every Also imagine the simple situation that at a time you require an attribute change. Because I would receive updates automatically the service would stop working for me. If you have realized it as a package then I could still use that explicite old version and are good to go. |
@julmot I can totally understand your point of staying at a stable version with a package manager. In fact, I tried Bower. It did not work.Jaakko Salonen has written enough in Why We Should Stop Using Bower, but I have to repeat how terrible Bower is. Since this project is hosted on GitHub Pages, all the front-end dependencies need to be committed to the repository or included as a git submodule. Using Bower or any other package manager means not no submodules, so I have commit the Ignoring the GitHub Pages for a moment, what if it is just a package for Bower? Well, Bower doesn’t support nested dependencies. This project requires What about other package managers like npm?As I said in a previous comment, a URL is hard-coded in order to support RequireJS per your request. This simply blocks package distribution from happening. But why exactly?
In the previous implementation it uses the This is a service.Twitter buttons, Google +1 buttons, etc. Those are all provided as services. They never change their interface except for the visual looking part. This is what I am intended to do. Changes will be backward compatible if they are going to happen. When any breaking change is really necessary, it will be something like |
Using a package manager will definitely not automatically loose the advantages when checking the dependencies into a Git repository. There can be good reasons why you would check-in dependencies, even with a package manager. See for example this article.
I may not understand you here, but in fact Bower was intended to handle nested dependencies. If you download a jQuery plugin for example, bower detects that this plugin needs jQuery (because it was listed as
Why not just have the default value pointing to the remote buttons.html on GitHub pages, but also allow setting a custom option for a local version of that file? Btw: This would need to be adjusted to also support the file-protocol ( "#{if /^http:/.test document.location then "http" else "https"}://buttons.github.io/" |
Git submodule can handle this case better.
Bower install all nested dependencies as sibling dependencies. No workaround to it at all. Although it does not make too much sense to keep dependencies nested like
It has to work out of the box. Otherwise, users will open GitHub issues without reading the documentation. The default remote URL can be broken as I have said in the previous comment. Giving an option in front-end means that you must set a global variable before this script is loaded, which is an extra dependency. Again, some people don't like documentation.
The protocol detection is only to avoid a mixed HTTP/HTTPS content security warning on very old IE. If the parent page uses |
Making the following necessary:
means to also disallow usage with e.g. RequireJS. RequireJS will not create the id, but the same script tag. And this will cause nothing to happen.
The text was updated successfully, but these errors were encountered: