For my Java project which uses Maven I have added Twitters Bootstrap lately to my repository on GitHub. Now I have noticed that my GitHub language statistic changed from
to
Since I didn't write the JS part, is there a way to manage that this isn't counted as mine or how would one normally manage foreign JS code in a GitHub repository or projects in general
I have faced that problem lately, too. There are several ways to deal with it:
use the performance optimized versions, for instance bootstrap.min.js instead of bootstrap.js etc. GitHub uses the file size to determine the language proportion of each repository. This won't reduce it to zero, but at least it reduces the proportion
This might be what you want: GitHub has a vendor list with regular expressions which are exluced from the language graph. There you will see, that jQuery is already part of the exclusion. There is also a pending pull request to add Twitter Bootstrap. If this does not get pass you can always add the files to a directory called vendor there they will be excluded from the statistics.
use the Maven AntRun Plugin: With it you could simply download the JavaScript library files on request with Ant Get
there are also Maven repositories for these JavaScript libraries: Bootstrap-Maven. However, the files are mounted at /ext/bootstrap/
and I have no idea how this helps
there are even more solutions, like Maven War Plugin using overlays.
Finally my advice: just put the files into your repository. I have looked into some bigger projects on GitHub using jQuery and Twitter Bootstrap and they all put their JavaScript library files into the repository.
The advantage of these JavaScript library files is that they don't have to be compiled what so ever. Use this advantage and don't add additional burdens for the sake of aesthetic. Best practice seems to be adding it to the repository and live with the stupid language graph. Who knows, maybe certain files will be ignored in the future.
The question is fairly old, but for future reference, it should be noted that GitHub added in 2014 a new feature to handle this thing. Possibly thanks to an open issue on the linguist repository.
This feature allows regarding certain files as libraries, documentation or a specific language.
Just add .gitattributes
file to your repository. For example, to ignore a library folder, just add the line:
library/* linguist-vendored
Or to set the docs folder, add the line:
docs/* linguist-documentation
More examples can be found here.
Two observations:
Use git submodules or put your 3rd party files in a directory called 'vendor'. Then Github will not count them as part of your code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With