In a significant milestone for web development, GitHub has completely removed jQuery as a dependency from its frontend codebase. This move marks the end of a years-long, incremental journey toward embracing modern browser standards. Instead of replacing jQuery with another library or framework, GitHub now relies entirely on native JavaScript APIs to deliver a robust, performant, and maintainable user experience.
The transition reflects broader industry trends toward leaner, more standards-compliant web applications. It also highlights how web standards have matured to the point where legacy libraries like jQuery are no longer necessary for complex, enterprise-scale sites.
Why jQuery Was Essential in the Early Days
When GitHub.com first adopted jQuery in late 2007, the web landscape was far less standardized than it is today. Google Chrome had not yet launched, and browser inconsistencies made cross-platform development a challenge. jQuery provided a unified interface for DOM manipulation, event handling, AJAX requests, and animations—features that were either missing or inconsistently implemented across browsers at the time.
Thanks to jQuery, GitHub’s small development team could rapidly prototype and deploy new features without worrying about browser compatibility. The library’s simplicity and reliability made it a cornerstone of GitHub’s early frontend architecture. It even inspired the creation of extension libraries like pjax and facebox, which became foundational components of the platform.
The Evolution of Web Standards
As GitHub grew, so did its engineering team and codebase. The company developed a dedicated group focused on code quality and maintainability. Over time, the team recognized that technical debt was accumulating around dependencies like jQuery—dependencies that once provided immense value but had become less essential as web standards improved.
Modern browsers now support features that jQuery once provided as a polyfill:
- Element Selection: The
$(selector)
pattern can be replaced withquerySelectorAll()
. - Class Manipulation: CSS class switching is now handled by the native
Element.classList
API. - Animations: CSS animations and transitions have largely replaced JavaScript-based animations.
- AJAX: The Fetch API provides a modern, promise-based alternative to
$.ajax
. - Event Handling: The
addEventListener()
interface is stable and consistent across browsers.
Additionally, many of jQuery’s syntactic conveniences have been rendered redundant by advancements in JavaScript itself. For example, method chaining—once a hallmark of jQuery’s API—no longer aligns with GitHub’s preference for explicit, statically analyzable code. The team also sought to introduce static type checking with Flow, which was easier to integrate with vanilla JavaScript than with jQuery’s chaining syntax.
Incremental Decoupling: A Pragmatic Approach
Removing jQuery from a codebase as large and complex as GitHub’s was not a task to be undertaken lightly. Rather than attempting a “big bang” rewrite, the team adopted a measured, incremental approach.
Key strategies included:
- Tracking jQuery Usage: The team established metrics to monitor the ratio of jQuery calls to overall code. This graph was tracked over time to ensure that jQuery usage was steadily decreasing.
- Discouraging New jQuery Code: Automation tools like
eslint-plugin-jquery
were introduced to block new jQuery imports and flag existing usage during code reviews. - Legacy Code Annotations: Older code that still relied on jQuery was marked with special comments, signaling to developers that this code did not reflect current best practices.
- Pull Request Bots: Automated bots were deployed to notify the team whenever new jQuery-related code was introduced, enabling early intervention and education.
- Internal Library Refactoring: Interfaces for legacy plugins like pjax and facebox were preserved, but their implementations were rewritten in vanilla JavaScript. Static type checking helped ensure these refactors were safe and reliable.
- Custom Builds: As features were migrated away from jQuery, the team removed unused modules from their custom jQuery build, further reducing bundle size and preventing new code from relying on deprecated features.
- Progressive Enhancement: GitHub increasingly relied on plain HTML as the foundation for new features, adding JavaScript behaviors only as progressive enhancements. This ensured that core functionality remained accessible even without JavaScript enabled.
Embracing Custom Elements and Web Components
As part of the transition away from jQuery, GitHub also began to adopt modern web component standards. Custom Elements, introduced as part of the Web Components v1 specification, allow developers to create reusable, encapsulated components using native browser APIs.
GitHub’s approach to custom elements emphasizes progressive enhancement. For example, the <local-time>
element displays a raw timestamp by default and upgrades to show the time in the user’s local timezone when JavaScript is available. Similarly, the <details-dialog>
element is interactive even without JavaScript, but gains additional accessibility features when scripts are enabled.
While Shadow DOM offers powerful encapsulation for web components, GitHub has been cautious about adopting it due to performance concerns with current polyfills. The team remains optimistic about the future of web components as browser support continues to improve.
Benefits of Removing jQuery
The decision to remove jQuery has yielded several tangible benefits for GitHub:
- Reduced Technical Debt: By eliminating a legacy dependency, GitHub has simplified its codebase and reduced long-term maintenance costs.
- Improved Performance: Removing jQuery has decreased JavaScript bundle sizes, resulting in faster page loads and execution times.
- Greater Reliability: Relying on web standards ensures that GitHub’s frontend is more resilient to future changes in browser technology.
- Enhanced Developer Experience: Developers now use MDN Web Docs as their primary reference, fostering a deeper understanding of native browser APIs.
- Accessibility and Progressive Enhancement: The shift toward vanilla JavaScript and web standards has made GitHub’s interface more accessible and robust, even for users with JavaScript disabled.
Lessons for the Wider Web Development Community
GitHub’s journey away from jQuery is a case study in thoughtful, incremental technical evolution. While jQuery remains widely used across the web, its necessity has diminished as browser standards have matured.
For teams considering a similar transition, GitHub’s experience offers several key lessons:
- Start Small: Begin by tracking usage and discouraging new jQuery code.
- Automate Enforcement: Use tools like ESLint plugins to prevent backsliding.
- Refactor Incrementally: Rewrite legacy code in manageable chunks, preserving interfaces where necessary.
- Embrace Progressive Enhancement: Build on a solid HTML foundation and add JavaScript behaviors as enhancements.
- Monitor and Educate: Keep the team informed and involved throughout the process.
Conclusion
GitHub’s successful removal of jQuery from its frontend codebase demonstrates the power of incremental improvement and the importance of embracing modern web standards. By relying on native browser APIs and progressive enhancement, GitHub has created a more performant, maintainable, and accessible platform for millions of users worldwide.
As the web continues to evolve, GitHub’s experience serves as an inspiration for other organizations looking to modernize their frontend architectures and reduce technical debt.
Read more such articles from our Newsletter here.