{"id":14953,"library":"t3js","title":"T3 JavaScript Framework","description":"T3 is a client-side JavaScript framework for building large-scale web applications, developed and battle-hardened at Box. Its current stable version is 2.7.0. Unlike many modern frameworks, T3 is explicitly not an MVC framework and is designed to be unopinionated, providing a foundational structure for scalable client-side code rather than an all-encompassing solution. It promotes loose coupling, explicit dependencies, and progressive enhancement, allowing integration with other libraries like jQuery, Backbone, or React. T3 defines functionality through three core component types: Services (utility libraries), Modules (managing DOM element interactions), and Behaviors (mixins for shared event handling). Its release cadence has been irregular, with the last significant updates around 2017, focusing on stability rather than active feature development.","status":"maintenance","version":"2.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/box/t3js","tags":["javascript","framework","browser","client-side","modular","component"],"install":[{"cmd":"npm install t3js","lang":"bash","label":"npm"},{"cmd":"yarn add t3js","lang":"bash","label":"yarn"},{"cmd":"pnpm add t3js","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for specific T3 builds (e.g., t3-jquery.js) to support older browsers like IE8 and jQuery versions 1.8.0+.","package":"jquery","optional":true}],"imports":[{"note":"T3.js exposes the 'Box' object as a global variable after being loaded via a <script> tag. It does not provide CommonJS or ES module exports, so direct 'import' or 'require' statements will not work.","wrong":"import { Box } from 't3js';\n// OR\nconst Box = require('t3js');","symbol":"Box","correct":"<!-- Load T3.js via script tag in HTML -->\n<script src=\"https://cdn.rawgit.com/box/t3js/v2.7.0/dist/t3.js\"></script>\n\n// Then access globally in your JavaScript\nconst app = Box.Application;"},{"note":"The core application instance, 'Box.Application', is accessed directly as a property of the global 'Box' object. No direct module import for this symbol exists.","wrong":"import { Application } from 't3js';\n// OR\nconst app = require('t3js').Application;","symbol":"Box.Application","correct":"Box.Application.addModule('my-module', function(context) { /* ... */ });"},{"note":"Modules are registered by calling the 'addModule' method directly on the global 'Box.Application' instance. It is not available as a standalone import or property of the 'Box' global itself.","wrong":"import { addModule } from 't3js.Application';\n// OR\nApplication.addModule('my-module', ...); // if 'Application' is not globally defined","symbol":"addModule","correct":"Box.Application.addModule('my-module', function(context) {\n    var moduleEl;\n    function init() { /* ... */ }\n    function destroy() { /* ... */ }\n    return { init: init, destroy: destroy };\n});"}],"quickstart":{"code":"<!-- index.html -->\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>T3 Quickstart</title>\n    <!-- Load T3.js - ensure this path is correct or use a CDN -->\n    <script src=\"https://cdn.rawgit.com/box/t3js/v2.7.0/dist/t3.js\"></script>\n</head>\n<body>\n    <div data-module=\"my-greeter\">\n        <h1 data-element=\"greeting-message\">Loading...</h1>\n        <button data-behavior=\"greet-button\">Say Hello</button>\n    </div>\n\n    <script>\n        // Define a T3 Module\n        Box.Application.addModule('my-greeter', function(context) {\n            var greetingMessageElement;\n\n            function init() {\n                greetingMessageElement = context.getElement('greeting-message');\n                // Attach a behavior for declarative event handling\n                context.attachBehavior('greet-button', greetBehavior);\n                updateGreeting('Initial message');\n            }\n\n            function destroy() {\n                greetingMessageElement = null;\n            }\n\n            function updateGreeting(message) {\n                if (greetingMessageElement) {\n                    greetingMessageElement.textContent = message;\n                }\n            }\n\n            // Define a Behavior\n            var greetBehavior = {\n                onclick: function() {\n                    const myService = context.getService('my-time-service');\n                    const time = myService ? myService.getCurrentTime() : 'unknown time';\n                    updateGreeting(`Hello from T3 at ${time}!`);\n                }\n            };\n\n            return {\n                init: init,\n                destroy: destroy,\n                // Expose a method if needed for other modules/services\n                updateMessage: updateGreeting\n            };\n        });\n\n        // Define a T3 Service\n        Box.Application.addService('my-time-service', function() {\n            function getCurrentTime() {\n                return new Date().toLocaleTimeString();\n            }\n            return { getCurrentTime: getCurrentTime };\n        });\n\n        // Initialize the T3 Application when the DOM is ready\n        document.addEventListener('DOMContentLoaded', function() {\n            Box.Application.init();\n            console.log('T3 Application Initialized.');\n            // You can also get a service directly after init\n            const timeService = Box.Application.getService('my-time-service');\n            if (timeService) {\n                console.log('Current time via service:', timeService.getCurrentTime());\n            }\n        });\n    </script>\n</body>\n</html>","lang":"javascript","description":"This quickstart demonstrates how to define and initialize a T3 module, attach a behavior for event handling, define a service, and initialize the entire T3 application within an HTML page. It showcases core T3 patterns like `data-module` attributes, `Box.Application.addModule`, `context.attachBehavior`, and `context.getService`."},"warnings":[{"fix":"Refer to the official migration guide for T3 1.5.1 to 2.0.0 (e.g., http://t3js.org/docs/getting-started/migrating-to-2-0-0) to understand necessary architectural and API changes.","message":"Version 2.0.0 introduced significant breaking changes, including the removal of service exports from the T3 core and changes to internal APIs. Applications upgrading from 1.x to 2.x will require code modifications.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Always use `t3js@2.0.1` or a more recent version (e.g., `2.7.0`) instead of `t3js@2.0.0` to ensure stability and correctness.","message":"The initial v2.0.0 release had issues with its release script, potentially leading to malformed builds or unexpected behavior. It is strongly advised to use version 2.0.1 or later.","severity":"gotcha","affected_versions":"=2.0.0"},{"fix":"Ensure T3.js is loaded in your HTML using a `<script>` tag before any custom JavaScript code that relies on it. Integrate it into modern bundlers using shimming or global exposure configurations, if necessary.","message":"T3.js is primarily designed for use as a global library loaded via a <script> tag. It does not natively support modern module patterns like CommonJS `require()` or ES Module `import` syntax, which can lead to conflicts or difficulties in contemporary build environments.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider the long-term implications for new projects; T3 might be a robust choice for legacy applications but less ideal for greenfield development requiring active community support. For existing projects, plan for potential self-maintenance or migration if significant new requirements arise.","message":"The project appears to be in maintenance mode, with the last significant release (v2.7.0) occurring in 2017. While the framework is stable, active feature development or prompt bug fixes for newly discovered issues are unlikely.","severity":"deprecated","affected_versions":">=2.7.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure that the `<script>` tag for `t3.js` is placed in your HTML *before* any custom JavaScript code that uses `Box.Application` or other T3 components. Verify the script path and network availability.","cause":"The T3.js library script has not been loaded, or it was loaded after your application code attempted to access the global 'Box' object.","error":"ReferenceError: Box is not defined"},{"fix":"Check the browser's developer console for errors during script loading. If you are using an async script load or defer, ensure your application code waits for the `DOMContentLoaded` event before interacting with T3.","cause":"This error typically indicates that the `Box.Application` object is not available or fully initialized when `addModule` is called, usually because the `t3.js` script failed to load or loaded out of order.","error":"TypeError: Box.Application.addModule is not a function"},{"fix":"Verify that the string value in your HTML's `data-module=\"my-module-name\"` attribute exactly matches the module name provided in your JavaScript: `Box.Application.addModule('my-module-name', ...)`.","cause":"This error occurs when `Box.Application.start()` (or `init()`) attempts to find a module for a DOM element with a `data-module` attribute, but no corresponding module has been registered with `Box.Application.addModule()` for that specific name.","error":"Error: Module 'my-module-name' not found on element"}],"ecosystem":"npm"}